﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>提现管理</title>
    <link href="~/plugins/layui/css/layui.css" rel="stylesheet" />
</head>
<body style="margin-left:10px;margin-top:10px;">
    <div id="ss" class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-input-inline" style="width: 30px;">
                <i class="layui-icon" style="font-size: 30px; color: #1E9FFF;">&#xe615;</i>
            </div>
            <div class="layui-input-inline" style="width: 150px;">
                <select name="pay_type">
                    <option value="0" selected="">= 全部支付类型 =</option>
                    @foreach (string name in Enum.GetNames(typeof(LJShengHelper.PayType)))
                    {
                        LJShengHelper.PayType type = (LJShengHelper.PayType)Enum.Parse(typeof(LJShengHelper.PayType), name, true);
                        <option value="@((int)type)">@name</option>
                    }
                </select>
                <select name="pay_status">
                    <option value="0" selected="">= 全部状态 =</option>
                    @foreach (string name in Enum.GetNames(typeof(LJShengHelper.PayStatus)))
                    {
                        LJShengHelper.PayStatus type = (LJShengHelper.PayStatus)Enum.Parse(typeof(LJShengHelper.PayStatus), name, true);
                        if (@name == "未支付")
                        {
                            <option value="@((int)type)" selected="selected">@name</option>
                        }
                        else
                        {
                            <option value="@((int)type)">@name</option>
                        }
                    }
                </select>
                <select name="lx">
                    <option value="100" selected="">= 全部类型 =</option>
                    <option value="0">会员消费</option>
                    <option value="1">会员注册</option>
                    <option value="2">商家注册</option>
                    <option value="3">商家提现</option>
                </select>
            </div>
            <div class="layui-input-inline" style="width: 150px;">
                <input type="text" value="@Request.QueryString["ddgid"]" name="ddgid" class="layui-hide" />
                <input type="text" value="@Request.QueryString["usergid"]" name="usergid" class="layui-hide" />
                <input type="text" placeholder="会员/商家手机号" name="account" class="layui-input" />
            </div>
            <div class="layui-input-inline" style="width: 150px;">
                <input type="text" placeholder="商家/套餐名称" name="name" class="layui-input" />
            </div>
            <div class="layui-input-inline" style="width: 150px;">
                <input class="layui-input" placeholder="提现开始日期" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" name="stime" value="@ViewBag.stime">
            </div>
            <div class="layui-form-mid">-</div>
            <div class="layui-input-inline" style="width: 150px;">
                <input class="layui-input" placeholder="提现结束日期" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" name="etime" value="@ViewBag.etime">
            </div>
            <div class="layui-input-inline" style="width: 150px;">
                <input class="layui-input" placeholder="打款开始日期" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" name="pstime" value="@ViewBag.pstime">
            </div>
            <div class="layui-form-mid">-</div>
            <div class="layui-input-inline" style="width: 150px;">
                <input class="layui-input" placeholder="打款结束日期" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" name="petime" value="@ViewBag.petime">
            </div>
            <div class="layui-input-inline">
                <button onclick="getlist(1);" class="layui-btn">给偶搜</button>
            </div>
        </div>
    </div>
    <div class="layui-form">
        <table class="layui-table">
            <thead>
                <tr>
                    <th>提现会员/商家</th>
                    <th>返利类型</th>
                    <th>金额</th>
                    <th>提现类型</th>
                    <th>提现状态</th>
                    <th>消费商家/操作人</th>
                    <th>提现/付款时间</th>
                    <th>收款码</th>
                </tr>
            </thead>
            <tbody id="tbody">
                <script id="tpl" type="text/html">
                    {{each list as item index}}
                    <tr>
                        <td>{{item.account}}({{item.real_name}})</td>
                        <td>
                            {{if item.lx=="1"}}
                            会员注册
                            {{else if item.lx=="2"}}
                            商家注册
                            {{else if item.lx=="0"}}
                            会员消费
                            {{else if item.lx=="3"}}
                            商家提现
                            {{else}}
                            未知
                            {{/if}}
                        </td>
                        <td>{{item.rmb}}</td>
                        <td  id="pay{{item.gid}}">
                            {{if item.pay_type=="1"}}
                            支付宝
                            {{else if item.pay_type=="2"}}
                            微信
                            {{else}}
                            线下汇款
                            {{/if}}
                        </td>
                        <td id="{{item.gid}}">
                            {{if item.pay_status=="1"}}
                            <span style="color:green;">支付成功</span>
                            {{else if item.pay_status=="2"}}
                            <button class="layui-btn layui-btn-mini" onclick="fk('{{item.gid}}','{{item.rmb}}','{{item.account}}','{{item.real_name}}','@(LJShengHelper.EWM){{item.ewm}}','{{item.khh}}','{{item.khm}}','{{item.kahao}}','2');">微信付款</button>
                            <br /><button class="layui-btn layui-btn-mini layui-btn-normal" onclick="fk('{{item.gid}}','{{item.rmb}}','{{item.account}}','{{item.real_name}}','@(LJShengHelper.EWM){{item.ewm}}','{{item.khh}}','{{item.khm}}','{{item.kahao}}','3');">银行打款</button>
                            <br /><span style="color:red;">未支付</span>
                            <br /><button class="layui-btn layui-btn-mini layui-btn-danger" onclick="wxfk('{{item.gid}}','{{item.rmb}}','{{item.real_name}}','{{item.openid}}','{{item.qx}}');">自动付款</button>
                            {{else}}
                            系统撤销
                            {{/if}}
                        </td>
                        <td>{{item.name}}<br />{{item.gly}}</td>
                        <td>{{item.addtime}}<br />{{item.pay_time}}</td>
                        <td><img style="width:80px;height:80px;" onerror="this.src = '/images/nopic.png'" src="@(LJShengHelper.EWM){{item.ewm}}" /></td>
                    </tr>
                    {{/each}}
                </script>
            </tbody>
        </table>
    </div>
    <div id="fk" class="layui-hide">
        <table class="layui-table">
            <colgroup>
                <col width="80">
                <col width="200">
                <col>
            </colgroup>
            <tbody>
                <tr>
                    <td>收款账户</td>
                    <td id="yh"></td>
                </tr>
                <tr>
                    <td>收款金额</td>
                    <td id="rmb" style="color:red;text-align:center;"></td>
                </tr>
                <tr>
                    <td>收款人信息</td>
                    <td id="account" style="color:blue;text-align:center;"></td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align:center;"><button class="layui-btn text-red" onclick="upfk();">付款成功以后切记要点击本按钮更新用户提现为已付款状态</button></td>
                </tr>
                <tr>
                    <td>操作代码<label id="pay_type" class="layui-hide"></label></td>
                    <td id="gid" style="text-align:center;"></td>
                </tr>
            </tbody>
        </table>
    </div>
    <div id="page"></div>
    共 <label id="pages">0</label> 页, <label id="count">0</label> 条数据<em style="color:red;">当前查询条件总提现=<label id="parame1"></label>(已提现=<label id="parame2"></label>)(未提现=<label id="parame3"></label>)</em> <a href="javascript: daochu();" class="layui-btn">导出当前查询的数据</a>
    <label id="Controllers" class="layui-hide">pay</label>
    <script src="~/js/jquery.js"></script>
    <script src="~/plugins/layui/layui.js"></script>
    <script src="~/js/template-web.js"></script>
    <script src="~/js/list.js"></script>
    <script src="~/js/daochu.js"></script>
    <script>
        function fk(gid, rmb, account, real_name, ewm, khh, khm, kahao, pay_type) {
            document.getElementById("pay_type").innerHTML = pay_type;
            document.getElementById("gid").innerHTML = gid;
            document.getElementById("rmb").innerHTML = rmb;
            document.getElementById("account").innerHTML = account + "(" + real_name + ")";
            if (pay_type == 2) {
                document.getElementById("yh").innerHTML = "<img src=\"" + ewm + "\" style=\"width: 200px; height: 250px;\" />";
            }
            else
            {
                document.getElementById("yh").innerHTML = "开户行:" + khh + "<br /><br />开户名:" + khm + "<br /><br />卡号:" + kahao;
            }
            layer.open({
                type: 1,
                title: '确认付款(请付款时候认真核对收款人和付款金额)',
                skin: 'layui-layer-rim', //加上边框
                area: ['500px', '500px'], //宽高
                content: document.getElementById("fk").innerHTML
            });
        }
        function upfk() {
            layer.confirm('请付款完成以后在点此操作哦', {
                btn: ['已付款', '取消'] //按钮
            }, function () {
                $.ajax({
                    url: "/ljsheng/upfk",
                    data: "gid=" + document.getElementById('gid').innerHTML + "&pay_type=" + document.getElementById('pay_type').innerHTML+"&Cache=" + Math.random(),
                    type: "post",
                    cache: false,
                    timeout: 8000,
                    dataType: "json",
                    ContentType: "application/json; charset=utf-8",
                    error: function () { layer.msg("请求超时"); },
                    beforeSend: function () { },
                    success: function (data) {
                        if (data.result == 200) {
                            $("#" + document.getElementById("gid").innerHTML).html('<span style="color:green;">支付成功</span>');
                            layer.msg(data.data, { icon: 1 });
                            if (document.getElementById('pay_type').innerHTML == "3")
                            {
                                $("#pay" + document.getElementById("gid").innerHTML).html('<span style="color:green;">线下付款</span>');
                            }
                        }
                        else {
                            layer.msg(data.data);
                        }
                    },
                });
            });
        }
        function wxfk(gid, rmb, real_name, openid,qx) {
            layer.confirm('确定要自动付款[' + rmb + '],给用户(' + real_name + ')吗?<br />对方帐号当前是:' + qx + '<br />注意账户未审核会导致付款给不一样的微信!' + qx + '<br />审核是指系统的会员认证姓名要和会员登录的微信里的银行卡认证的姓名一致!', {
                btn: ['确认付款', '取消'] //按钮
            }, function (index) {
                layer.close(index);
                $.ajax({
                    url: "/ljsheng/wxfk",
                    data: "gid=" + gid + "&real_name=" + real_name + "&openid=" + openid + "&Cache=" + Math.random(),
                    type: "post",
                    cache: false,
                    timeout: 8000,
                    dataType: "json",
                    ContentType: "application/json; charset=utf-8",
                    error: function () { layer.msg("请求超时"); },
                    beforeSend: function () { },
                    success: function (data) {
                        if (data.result == 200) {
                            $("#" + gid).html('<span style="color:green;">支付成功</span>');
                            layer.msg(data.data, { icon: 1 });
                        }
                        else {
                            layer.msg(data.data);
                        }
                    },
                });
            });
        }
    </script>
</body>
</html>
